﻿using System.Windows.Automation;
using ProdControls.Interfaces;
using ProdControls.UIAPatterns;

namespace ProdControls.Bridges
{
    public static class ExpandCollapseBridge
    {
        /// <summary>
        ///   Displays all child nodes, controls, or content of the AutomationElement.
        /// </summary>
        /// <example>
        ///   this.Expand(this);
        /// </example>
        public static void ExpandHook(this IExpandCollapse extension, BaseProdControl control)
        {
            UiaExpand(control);
        }

        private static void UiaExpand(BaseProdControl control)
        {
            ExpandCollapseHelper.Expand(control.UiaElement);
        }

        /// <summary>
        ///   Hides all descendant nodes, controls, or content of the AutomationElement.
        /// </summary>
        /// <example>
        ///   this.Collapse(this);
        /// </example>
        public static void CollapseHook(this IExpandCollapse extension, BaseProdControl control)
        {
            UiaExpand(control);
        }

        private static void UiaCollapse(BaseProdControl control)
        {
            ExpandCollapseHelper.Collapse(control.UiaElement);
        }

        /// <summary>
        ///   Gets the state, expanded or collapsed, of the control.
        /// </summary>
        /// <value> The state of the control. </value>
        public static ExpandCollapseState ExpandCollapseStateHook(BaseProdControl control)
        {
            return UiaExpandCollapseState(control);
        }

        private static ExpandCollapseState UiaExpandCollapseState(BaseProdControl control)
        {
            return ExpandCollapseHelper.ExpandCollapseState(control.UiaElement);
        }
    }
}